package com.evan.webadmin.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.evan.webadmin.biz.dao.ExamPaperDetailMapper;
import com.evan.webadmin.biz.model.ExamPaperDetail;
import com.evan.webadmin.biz.service.IExamPaperDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 试卷详情表 服务实现类
 * </p>
 *
 * @author Pavel
 * @since 2025-02-28
 */
@Service
public class ExamPaperDetailServiceImpl extends ServiceImpl<ExamPaperDetailMapper, ExamPaperDetail> implements IExamPaperDetailService {

    @Autowired
    private ExamPaperDetailMapper examPaperDetailMapper;

    @Override
    public List<ExamPaperDetail> detail(long surveyId) {
        QueryWrapper<ExamPaperDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("paper_id", surveyId);
        return examPaperDetailMapper.selectList(queryWrapper);
    }

    @Override
    public Long subjectUseAble(long subjectId) {
        QueryWrapper<ExamPaperDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("subject_id", subjectId);
        queryWrapper.eq("delete_flag", 0L);
        return examPaperDetailMapper.selectCount(queryWrapper);
    }
}
